package com.ht.module.info.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ht.module.info.entity.InfoOrderDetails;
import com.ht.module.info.mapper.InfoOrderDetailsMapper;
import com.ht.module.info.service.IInfoOrderDetailsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ht.util.CommMethod;
import com.ht.util.UserUtil;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 订单详情表 服务实现类
 * </p>
 *
 * @author Auto-generator
 * @since 2021-12-03
 */
@Service
public class InfoOrderDetailsServiceImpl extends ServiceImpl<InfoOrderDetailsMapper, InfoOrderDetails> implements IInfoOrderDetailsService {

    @Override
    public List<InfoOrderDetails> findByOrderId(String id) {
        QueryWrapper<InfoOrderDetails> qw=new QueryWrapper<>();
        qw.eq("tab.order_id",id);

        return baseMapper.findList(qw);
    }

    @Override
    public void updateState(String id, String val) {
        InfoOrderDetails info=new InfoOrderDetails();
        info.setId(id);
        info.setState(val);
        CommMethod.beanUpdate(info);
        baseMapper.updateById(info);
    }

    @Override
    public List<InfoOrderDetails> findByOrderIdAndMerchants(String id) {
        QueryWrapper<InfoOrderDetails> qw=new QueryWrapper<>();
        qw.eq("tab.order_id",id);
        qw.eq("tab.merchants_id", UserUtil.getUserId());
        return baseMapper.findList(qw);
    }
}
